home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amoszine 11
/
Amoszine 11 (Disk 2 of 2).adf
/
Ben_Wyatt_Source.lha
/
Rotation.AMOS
/
Rotation.amosSourceCode
Wrap
AMOS Source Code
|
2004-04-12
|
2KB
|
62 lines
' Rotation
' ~~~~~~~~
' by Ben Wyatt, bwyatt@paston.co.uk
'
' Rotates some graphics at any angle
' Needs it in degree mode - you can probably change it to radians if you're
' wierd, or to use AMCAFs Qsin and Qcos (also use Fplot/point or Turboplot/point)
Degree
Load Iff Fsel$("","","Select an IFF picture"),0
Screen Open 1,640,16,2,Hires : Curs Off : Screen To Back
Screen Display 1,128,37,320,16
Screen 0 : Screen Display 0,128,37+9,Screen Width,Screen Height
Screen 1 : Centre "Select centre point"
Screen 0 : Wait Vbl : Limit Mouse
Repeat
XM=X Screen(X Mouse) : YM=Y Screen(Y Mouse) : MK=Mouse Key
Until MK>0
Screen 0
' Grab each bit of the rotation (step of 5 degrees)
STP=5
For N=STP To 360 Step STP
_ROTATE[XM,YM,16,200,200,N]
Get Bob N/STP,200-16,200-16 To 200+16,200+16
No Mask N/STP
Next N
' Loop the animation
MK=False
Repeat
For N=STP To 360 Step STP
Paste Bob 100-16,100-16,N/STP
Wait Vbl
MK=(Mouse Key>0) or MK
Next N
Until MK
Procedure _ROTATE[XP,YP,R,XT,YT,ANG]
' Rotate area around centre point XP,YP to box with centre XT,YT and
' width/height R, at an angle ANG
For X=XT-R To XT+R
For Y=YT-R To YT+R
' Work out the distance from the centre point
DIST=Sqr((X-XT)*(X-XT)+(Y-YT)*(Y-YT))*256
If DIST>0
' Work out the angle
ANGT=Acos(((Y-YT)*256)/(DIST*1.0)) : If X-XT<0 : ANGT=360-ANGT : End If
Else
ANGT=0
End If
' Plot the pixel, of the colour of the source point :-?
Plot X,Y,Point(XP+(Sin(ANGT-ANG)*DIST)/256,YP+(Cos(ANGT-ANG)*DIST)/256)
Next Y
Next X
End Proc